import React, { Component } from 'react';
import {
  View,Text,StyleSheet,ScrollView,FlatList,Image
} from 'react-native';
import * as DATA from '../data/data';
import pxToDp from '../common/comm';

export default class Banner extends Component {
    // 构造
      constructor(props) {
        super(props);
        // 初始状态
          this.state = {
            index:this.props.navigation.state.params.index,
            url:DATA.share_banner + DATA.bannerImgs[this.props.navigation.state.params.index].bg,
            imgs:DATA.bannerImgs[this.props.navigation.state.params.index],
            height:0
        };
      }

    componentDidMount() {
        Image.getSize(this.state.url,(width, height)=>{
            this.setState({width,height});
        })
    }

  render() {
    return (
        <ScrollView>
            <Image source={{uri: this.state.url}}
                   style={{width: pxToDp(this.state.width), height: pxToDp(this.state.height)}} />
        </ScrollView>
    );
    }
}

